package com.mxw.client;

import com.mxw.disruptor.MessageProducer;
import com.mxw.disruptor.RingBufferWorkerPoolFactory;
import com.mxw.dto.TranslatorData;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.ReferenceCountUtil;

public class ClientHandler extends ChannelInboundHandlerAdapter {

    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {

        TranslatorData response = (TranslatorData) msg;
        //i消费者和生产者共用一个池，所以id不可以冲突,以后可以随机生成id(机器码:sessionId:标识)
        String producerId = "code:session:002";
        MessageProducer messageProducer = RingBufferWorkerPoolFactory.getInstance().getMessageProducer(producerId);
        messageProducer.onData(response, ctx);

    }
}
